/**
 * Title: PlusActionProvider.java
 * Description:
 * author: kotomifi
 * date: Jul 16, 2014
 * ©2014 apping 社区
 */
package com.apping.demo.bbs.provider;


import com.sina.weibo.sdk.demo.R;
import com.apping.demo.bbs.AddArticleActivity;
import com.apping.demo.bbs.ArticleActivity;
import com.apping.demo.bbs.LoginActivity;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.media.audiofx.BassBoost.Settings;
import android.util.Log;
import android.view.ActionProvider;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SubMenu;
import android.view.View;
import android.widget.Toast;

/**
 *
 */
public class PlusActionProvider extends ActionProvider implements 
	OnMenuItemClickListener {
	
	private Class<?> cls;
	private Intent mIntent;
	private Context mContext;
	
	public PlusActionProvider(Context context) {
		super(context);
		this.mContext = context;
	}
	
	@Override
	public View onCreateActionView() {
		return null;
	}
	
	@Override
	public void onPrepareSubMenu(SubMenu subMenu) {
		subMenu.clear();
		subMenu.add(0, 0, 0, mContext.getString(R.string.plus_article))
			.setIcon(R.drawable.ofm_group_chat_icon)
			.setOnMenuItemClickListener(this);
		subMenu.add(0, 1, 1, mContext.getString(R.string.manage_article))
			.setIcon(R.drawable.ofm_add_icon)
			.setOnMenuItemClickListener(this);
		subMenu.add(0, 2, 2, mContext.getString(R.string.account_setting))
			.setIcon(R.drawable.ofm_video_icon)
			.setOnMenuItemClickListener(this);
	}
	
	@Override
	public boolean hasSubMenu() {
		return true;
	}
	
	@Override
	public boolean onMenuItemClick(MenuItem menuItem) {
	
		switch(menuItem.getItemId()) {
		case 0:
			setNextActivity(AddArticleActivity.class);
			nextActivity();
			break;
		case 1:
			//setNextActivity(SettingActivity.class);
			//nextActivity();
			break;
		case 2:
			//setNextActivity(AccountActivity.class);
			//nextActivity();
			break;
		default:
			break;
		}
		return true;
	}
	
	public void setIntent(Intent intent) {
		mIntent = intent;
	}
	
	public void setNextActivity(Class<?> cls) {
		this.cls = cls;
	}
	
	public void nextActivity() {
		mIntent = new Intent();
		mIntent.setClass(mContext, cls);
		mContext.startActivity(mIntent);
	}
}
